package cn.echo.sharding.strategy;

/**
 * 节点分期策略
 * @author lonyee
 *
 */
public class PeriodDataNode {

	/**
     * 获取按月分表结构
     */
	public static String getMonthPeriodDataNodes(String tablePrefix, int startYear, int endYear) {
    	StringBuilder stringBuilder = new StringBuilder(30);
    	for(int i=startYear; i<=endYear; i++) {
    		for(int j=1; j<=12; j++) { //12月
				stringBuilder.append(tablePrefix);
				stringBuilder.append(i);
				stringBuilder.append(String.format("%02d", j));
				stringBuilder.append(",");
    		}
    	}
    	if (stringBuilder.length()>0) {
    		stringBuilder.deleteCharAt(stringBuilder.length()-1);
    	}
    	return stringBuilder.toString();
    }
}
